package com.fourhats.model;

import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

@Entity
@Table(name="product")
public class Product extends com.fourhats.model.Entity  {
	
	@Column(name="name")
	private String name;
	
	@ManyToOne
    @JoinColumn(name="categoryId")
	private Category category;
	
	@Column(name="imagePath")
	private String imagePath;
	
	@Column(name="enable")
	private boolean enable;
	
	@OneToMany(mappedBy="product")
    private Set<Item> items;
	
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public Category getCategory() {
		return category;
	}

	public void setCategory(Category category) {
		this.category = category;
	}

	public String getImagePath() {
		return imagePath;
	}

	public void setImagePath(String imagePath) {
		this.imagePath = imagePath;
	}

	public boolean isEnable() {
		return enable && this.category.isEnable();
	}

	public void setEnable(boolean enable) {
		this.enable = enable;
	}

	public Set<Item> getItems() {
		return items;
	}

	public void setItems(Set<Item> items) {
		this.items = items;
	}
}
